<?php

$GLOBALS['GOOGLE_USERNAME'] = '';
$GLOBALS['GOOGLE_PASSWORD'] = '';

define('DOC_ROOT', dirname(__FILE__));

function create_temp_dir()
{
    $filepath = DOC_ROOT ."tmp/dir_". random_digits(5);
    // make sure the name is unique
    while(glob($filepath))
    {
        $filepath = DOC_ROOT ."tmp/dir_". random_digits(5);
    }
    mkdir($filepath);
    return $filepath;
}

function random_digits($number, $start = 0)
{
    if(!$number) return null;
    // adding a 1 in front so we can get zeros in the first position
    $start = "1".$start.str_repeat(0, $number-1);
    $end = "1".str_repeat(9, $number);
    $random = rand($start, $end);
    // chop off the 1 to get the real random number
    return substr($random, 1);
}

?>